import Vue from 'vue'
import Vuex from 'vuex'

import {get_identity_auth,
  get_auth_view,
  set_identity_auth_views,
  get_identity_auth_views
} from "../api/index"

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    viewList:[],
    authView:[]
  },
  mutations: {
    setList(state,payload){
      state[payload.key]=payload.value
    }
  },
  actions: {
    async getIdentity({commit}){
      const {data}=await get_identity_auth()
      commit("setList",{
        key:"viewList",
        value:data.result
      })
    },
    async getAuthView({commit}){
      const {data}=await get_auth_view()
      commit("setList",{
        key:"authView",
        value:data.result
      })
    },
    async setAuthIdentityViews({commit},{type_id,views_id}){
      const {data}=await set_identity_auth_views(type_id,views_id)
      console.log(data);
      console.log({commit});
    },
    async getAuthIdentityViews({commit},type_id){
      console.log(type_id);
      const {data}=await get_identity_auth_views(type_id)
      console.log(data);
      console.log({commit});
    },
  },
  modules: {
    
  }
})
